cd3d0c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
import org.springframework.dao.DataRetrievalFailureException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
 import org.springframework.jdbc.support.JdbcUtils;
 import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
 
 /**
  * {@link RowMapper} implementation that converts a row into a new instance
@@ -163,18 +164,19 @@
public class BeanPropertyRowMapper<T> implements RowMapper<T> {
 	 * @return the converted name
 	 */
 	private String underscoreName(String name) {
+		if (!StringUtils.hasLength(name)) {
+			return "";
+		}
 		StringBuilder result = new StringBuilder();
-		if (name != null && name.length() > 0) {
-			result.append(name.substring(0, 1).toLowerCase());
-			for (int i = 1; i < name.length(); i++) {
-				String s = name.substring(i, i + 1);
-				if (s.equals(s.toUpperCase())) {
-					result.append("_");
-					result.append(s.toLowerCase());
-				}
-				else {
-					result.append(s);
-				}
+		result.append(name.substring(0, 1).toLowerCase());
+		for (int i = 1; i < name.length(); i++) {
+			String s = name.substring(i, i + 1);
+			String slc = s.toLowerCase();
+			if (!s.equals(slc)) {
+				result.append("_").append(slc);
+			}
+			else {
+				result.append(s);
 			}
 		}
 		return result.toString();
